<?php 
$oriurl = $_POST['sourceUrl'];

$pattern = '/^(http:\/\/)?(cache\.tianya\.cn|www\.tianya\.cn|tianya\.cn)';
$pattern .= '\/publicforum\/(?:.*)\/(\d+)\.shtml$/i';
if(preg_match($pattern, $oriurl))
{
	$oriurl = str_ireplace('tianya.cn', 'xtianya.cn', $oriurl);
	if($oriurl[0] != 'h')
		$oriurl = 'http://' . $oriurl;
	header('Location: '.$oriurl);
}
else
{
	echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>输入错误</title>
 </head>
 <body>
  <h1>请返回输入正确的天涯论坛帖子地址</h1>
  <a href="home.html">返回</a>
 </body>

</html>


<?
}

?>
